package com.zhw.controller;

import com.zhw.pojo.entry.DevPlan;
import com.zhw.pojo.vo.DevPlanVO;
import com.zhw.pojo.Result;
import com.zhw.service.DevPlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("dev")
public class DevPlanController {

    @Autowired
    DevPlanService devPlanService;

    @GetMapping("getByID")
    public Result getByID(Integer id){
        log.info("查询：{}的开发计划表",id);
        List<DevPlanVO> devPlanVO=devPlanService.getByID(id);
        return Result.success(devPlanVO);
    }



    @PostMapping("add")
    public Result add(@RequestBody DevPlan devPlan){
        log.info("添加一个新的计划：{}",devPlan);
        devPlanService.add(devPlan);
        return Result.success();
    }

    @PutMapping("update")
    public Result update(@RequestBody DevPlan devPlan){
        log.info("修改一个计划：{}",devPlan);
        devPlanService.update(devPlan);

        return Result.success();
    }


    @DeleteMapping("deleteByID")
    public Result deleteByID(Integer id){
        log.info("删除id:{}的信息",id);
        devPlanService.deleteById(id);
        return Result.success();
    }



}
